<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2005 Joshua Dechant                               |
// |                                                                      |   
// | Portions Copyright (c) 2004 The zen-cart developers                  |
// |                                                                      |   
// | http://www.zen-cart.com/index.php                                    |   
// |                                                                      |   
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// $Id: news_scroller.php v1.000 2005-02-04 dreamscape <dechantj@pop.belmont.edu>
//

  $date_selector = $db->Execute("select news_date_published from " . TABLE_NEWS_ARTICLES . " where news_status = '1' and to_days(news_date_published) <= to_days(now()) group by news_date_published desc limit " . (int)NEWS_SCROLLER_NUMBER_OF_DAYS);

	if ($date_selector->RecordCount() > 0) {
		require_once(DIR_WS_CLASSES . 'news.php');

		require_once(DIR_WS_FUNCTIONS . 'news.php');

		$article_array = array();
		while (!$date_selector->EOF) {
			$article = $db->Execute("select distinct n.article_id, nt.news_article_name, nt.news_article_text, nt.news_article_shorttext, n.news_image, nt.news_image_text, n.news_date_published from " . TABLE_NEWS_ARTICLES . " n left join " . TABLE_NEWS_ARTICLES_TEXT . " nt on n.article_id = nt.article_id and nt.language_id = '" . (int)$_SESSION['languages_id'] . "' where n.news_status = '1' and n.news_date_published = '" . $date_selector->fields['news_date_published'] . "' order by n.sort_order");
	
			$article_array[$newsDate]['newsDate'] = strtoupper(zen_date_long($date_selector->fields['news_date_published']));
	
			while (!$article->EOF) {
				$article_array[$newsDate]['articles'][] = array(
					'articleLink' => zen_href_link(FILENAME_NEWS_ARTICLE, 'article_id=' . $article->fields['article_id']),
					'articleName' => stripslashes($article->fields['news_article_name']),
					'articleSummary' => news_create_news_summary($article->fields['news_article_text'], $article->fields['news_article_shorttext']),
				);
	
				$article->MoveNext();
			}
	
			$date_selector->MoveNext();
		}

		require($template->get_template_dir('tpl_news_scroller.php',DIR_WS_TEMPLATE, $current_page_base, 'sideboxes'). '/tpl_news_scroller.php');
	
		$title =  BOX_HEADING_NEWS_SCROLLER;
		$left_corner = false;
		$right_corner = false;
		$right_arrow = false;
		$title_link = FILENAME_NEWS_INDEX;
	
		require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base, 'common') . '/' . $column_box_default);
	}
?>
